using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExecuteAlways]
public class GUIRoot : MonoBehaviour
{
    private GUIControl[] controls;
    private void Start()
    {
        controls = GetComponentsInChildren<GUIControl>();
    }
    //统一绘制子对象控件的内容
    private void OnGUI()
    {
        controls = GetComponentsInChildren<GUIControl>();
        //编辑状态下才会一直执行
        if (!Application.isPlaying)
        {
            controls = GetComponentsInChildren<GUIControl>();
        }
        for (int i = 0; i < controls.Length; i++)
        {
            controls[i].DrawGUI();
        }
    }
}
